package riverdale_emulator;

import riverdalerobotics.PandaBot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;

public class EmmaGui extends javax.swing.JFrame 
{

    // Emma GUI singleton
    static public EmmaGui m_emmaGui;
    /**
     * Creates new form EmmaGui
     */
    public EmmaGui() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        m_modeGroup = new javax.swing.ButtonGroup();
        m_leftJoystickXLabel = new javax.swing.JLabel();
        m_rightJoystickLabel = new javax.swing.JLabel();
        m_leftJoystickButtonsLabel = new javax.swing.JLabel();
        m_leftJoystickButton1 = new javax.swing.JToggleButton();
        m_leftJoystickButton2 = new javax.swing.JToggleButton();
        m_leftJoystickButton3 = new javax.swing.JToggleButton();
        m_leftJoystickButton4 = new javax.swing.JToggleButton();
        m_rightJoystickButton3 = new javax.swing.JToggleButton();
        m_rightJoystickButton4 = new javax.swing.JToggleButton();
        m_rightJoystickButton1 = new javax.swing.JToggleButton();
        m_rightJoystickButton2 = new javax.swing.JToggleButton();
        m_rightJoystickButtonsLabel = new javax.swing.JLabel();
        m_leftWheelJagLabel = new javax.swing.JLabel();
        m_leftWheelJagText = new javax.swing.JTextField();
        m_rightWheelJagLabel = new javax.swing.JLabel();
        m_rightWheelJagText = new javax.swing.JTextField();
        m_rightLiftJagLabel = new javax.swing.JLabel();
        m_rightLiftJagText = new javax.swing.JTextField();
        m_leftLiftJagLabel = new javax.swing.JLabel();
        m_leftLiftJagText = new javax.swing.JTextField();
        m_disabledModeRadio = new javax.swing.JRadioButton();
        m_autonomousModeRadio = new javax.swing.JRadioButton();
        m_teleopModeRadio = new javax.swing.JRadioButton();
        m_feedbackText = new javax.swing.JTextField();
        m_shootRotaryJagText = new javax.swing.JTextField();
        m_shootHopperJagLabel = new javax.swing.JLabel();
        m_shootHopperJagText = new javax.swing.JTextField();
        m_shootRotaryJagLabel = new javax.swing.JLabel();
        m_shootRotaryJagLabel1 = new javax.swing.JLabel();
        m_shootCamJagText = new javax.swing.JTextField();
        m_leftJoystickTrigger = new javax.swing.JToggleButton();
        m_rightJoystickTrigger = new javax.swing.JToggleButton();
        leftJoystick = new riverdale_emulator.JoystickWidget();
        rightJoystick = new riverdale_emulator.JoystickWidget();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Emma - Riverdale Robotics Emulator");

        m_leftJoystickXLabel.setText("Left Joystick");

        m_rightJoystickLabel.setText("Right Joystick");

        m_leftJoystickButtonsLabel.setText("Left Joystick Buttons");

        m_leftJoystickButton1.setText("1");
        m_leftJoystickButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftJoystickButton1ActionPerformed(evt);
            }
        });

        m_leftJoystickButton2.setText("2");
        m_leftJoystickButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftJoystickButton2ActionPerformed(evt);
            }
        });

        m_leftJoystickButton3.setText("3");
        m_leftJoystickButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftJoystickButton3ActionPerformed(evt);
            }
        });

        m_leftJoystickButton4.setText("4");
        m_leftJoystickButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftJoystickButton4ActionPerformed(evt);
            }
        });

        m_rightJoystickButton3.setText("3");
        m_rightJoystickButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_rightJoystickButton3ActionPerformed(evt);
            }
        });

        m_rightJoystickButton4.setText("4");
        m_rightJoystickButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_rightJoystickButton4ActionPerformed(evt);
            }
        });

        m_rightJoystickButton1.setText("1");
        m_rightJoystickButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_rightJoystickButton1ActionPerformed(evt);
            }
        });

        m_rightJoystickButton2.setText("2");
        m_rightJoystickButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_rightJoystickButton2ActionPerformed(evt);
            }
        });

        m_rightJoystickButtonsLabel.setText("Right Joystick Buttons");

        m_leftWheelJagLabel.setLabelFor(this);
        m_leftWheelJagLabel.setText("Left Wheel Jag");

        m_leftWheelJagText.setText("jTextField1");

        m_rightWheelJagLabel.setText("Right Wheel Jag");
        m_rightWheelJagLabel.setToolTipText("");

        m_rightWheelJagText.setText("jTextField1");

        m_rightLiftJagLabel.setText("Right Lift Jag");

        m_rightLiftJagText.setText("jTextField1");

        m_leftLiftJagLabel.setText("Left Lift Jag");

        m_leftLiftJagText.setText("jTextField1");
        m_leftLiftJagText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftLiftJagTextActionPerformed(evt);
            }
        });

        m_modeGroup.add(m_disabledModeRadio);
        m_disabledModeRadio.setSelected(true);
        m_disabledModeRadio.setText("Disabled");

        m_modeGroup.add(m_autonomousModeRadio);
        m_autonomousModeRadio.setText("Autonomous");

        m_modeGroup.add(m_teleopModeRadio);
        m_teleopModeRadio.setText("Teleop");

        m_feedbackText.setText("jTextField1");

        m_shootRotaryJagText.setText("jTextField1");

        m_shootHopperJagLabel.setText("Shoot Hopper Jag");

        m_shootHopperJagText.setText("jTextField1");

        m_shootRotaryJagLabel.setText("Shoot Rotary Jag");

        m_shootRotaryJagLabel1.setText("Shoot Cam Jag");

        m_shootCamJagText.setText("jTextField1");

        m_leftJoystickTrigger.setText("Trigger");
        m_leftJoystickTrigger.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_leftJoystickTriggerActionPerformed(evt);
            }
        });

        m_rightJoystickTrigger.setText("Trigger");
        m_rightJoystickTrigger.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_rightJoystickTriggerActionPerformed(evt);
            }
        });

        leftJoystick.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                leftJoystickPressed(evt);
            }
        });
        leftJoystick.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                leftJoystickDrag(evt);
            }
        });

        javax.swing.GroupLayout leftJoystickLayout = new javax.swing.GroupLayout(leftJoystick);
        leftJoystick.setLayout(leftJoystickLayout);
        leftJoystickLayout.setHorizontalGroup(
            leftJoystickLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 159, Short.MAX_VALUE)
        );
        leftJoystickLayout.setVerticalGroup(
            leftJoystickLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 159, Short.MAX_VALUE)
        );

        rightJoystick.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                rightJoystickPressed(evt);
            }
        });
        rightJoystick.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                rightJoystickDrag(evt);
            }
        });

        javax.swing.GroupLayout rightJoystickLayout = new javax.swing.GroupLayout(rightJoystick);
        rightJoystick.setLayout(rightJoystickLayout);
        rightJoystickLayout.setHorizontalGroup(
            rightJoystickLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 161, Short.MAX_VALUE)
        );
        rightJoystickLayout.setVerticalGroup(
            rightJoystickLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(m_shootRotaryJagLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(m_shootCamJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(m_disabledModeRadio))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addComponent(m_leftJoystickXLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(m_autonomousModeRadio)
                                .addGap(10, 10, 10)
                                .addComponent(m_teleopModeRadio)
                                .addGap(18, 18, 18)
                                .addComponent(m_feedbackText, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(m_leftJoystickTrigger)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(leftJoystick, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(58, 58, 58)
                        .addComponent(rightJoystick, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28)))
                .addGap(0, 21, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(m_shootRotaryJagLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(m_shootRotaryJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(81, 81, 81))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(m_leftLiftJagLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(m_leftLiftJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(m_leftWheelJagLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(m_leftWheelJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(11, 11, 11)
                                        .addComponent(m_leftJoystickButtonsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(m_leftJoystickButton1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(m_leftJoystickButton2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(m_leftJoystickButton3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(m_leftJoystickButton4)))))
                        .addGap(44, 44, 44)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(m_rightLiftJagLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(m_rightLiftJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(m_rightWheelJagLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(m_rightWheelJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(m_shootHopperJagLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(m_shootHopperJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(m_rightJoystickLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(m_rightJoystickTrigger, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(m_rightJoystickButtonsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(m_rightJoystickButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(m_rightJoystickButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(m_rightJoystickButton3)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(m_rightJoystickButton4)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_autonomousModeRadio)
                    .addComponent(m_teleopModeRadio)
                    .addComponent(m_disabledModeRadio)
                    .addComponent(m_feedbackText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_leftJoystickXLabel)
                    .addComponent(m_rightJoystickLabel)
                    .addComponent(m_rightJoystickTrigger)
                    .addComponent(m_leftJoystickTrigger))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(leftJoystick, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rightJoystick, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_leftJoystickButtonsLabel)
                    .addComponent(m_rightJoystickButtonsLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_leftJoystickButton1)
                    .addComponent(m_leftJoystickButton2)
                    .addComponent(m_leftJoystickButton3)
                    .addComponent(m_leftJoystickButton4)
                    .addComponent(m_rightJoystickButton1)
                    .addComponent(m_rightJoystickButton2)
                    .addComponent(m_rightJoystickButton3)
                    .addComponent(m_rightJoystickButton4))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_leftWheelJagLabel)
                    .addComponent(m_leftWheelJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(m_rightWheelJagLabel)
                    .addComponent(m_rightWheelJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_leftLiftJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(m_rightLiftJagLabel)
                    .addComponent(m_rightLiftJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(m_leftLiftJagLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_shootRotaryJagLabel)
                    .addComponent(m_shootHopperJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(m_shootHopperJagLabel)
                    .addComponent(m_shootRotaryJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(m_shootRotaryJagLabel1)
                    .addComponent(m_shootCamJagText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void m_leftJoystickButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_leftJoystickButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftJoystickButton1ActionPerformed

    private void m_leftJoystickButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_leftJoystickButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftJoystickButton2ActionPerformed

    private void m_leftJoystickButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_leftJoystickButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftJoystickButton3ActionPerformed

    private void m_leftJoystickButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_leftJoystickButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftJoystickButton4ActionPerformed

    private void m_rightJoystickButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_rightJoystickButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_rightJoystickButton3ActionPerformed

    private void m_rightJoystickButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_rightJoystickButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_rightJoystickButton4ActionPerformed

    private void m_rightJoystickButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_rightJoystickButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_rightJoystickButton1ActionPerformed

    private void m_rightJoystickButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_rightJoystickButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_rightJoystickButton2ActionPerformed

    private void m_leftLiftJagTextActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_m_leftLiftJagTextActionPerformed
    {//GEN-HEADEREND:event_m_leftLiftJagTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftLiftJagTextActionPerformed

    private void m_leftJoystickTriggerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_leftJoystickTriggerActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_leftJoystickTriggerActionPerformed

    private void m_rightJoystickTriggerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_rightJoystickTriggerActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_m_rightJoystickTriggerActionPerformed

    private void leftJoystickDrag(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_leftJoystickDrag
        leftJoystick.setXY(evt.getX(), evt.getY());
    }//GEN-LAST:event_leftJoystickDrag

    private void rightJoystickDrag(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rightJoystickDrag
        rightJoystick.setXY(evt.getX(), evt.getY());
    }//GEN-LAST:event_rightJoystickDrag

    private void leftJoystickPressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_leftJoystickPressed
        leftJoystick.setXY(evt.getX(), evt.getY());
    }//GEN-LAST:event_leftJoystickPressed

    private void rightJoystickPressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rightJoystickPressed
        rightJoystick.setXY(evt.getX(), evt.getY());
    }//GEN-LAST:event_rightJoystickPressed


    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) 
    {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EmmaGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EmmaGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EmmaGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EmmaGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() 
        {
            @Override
            public void run() 
            {
                // Create the GUI
                m_emmaGui = new EmmaGui();
                m_emmaGui.setVisible(true);
                // create the robot thread
                PandaBot robot = new PandaBot();
                (new Thread(robot)).start();
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private riverdale_emulator.JoystickWidget leftJoystick;
    private javax.swing.JRadioButton m_autonomousModeRadio;
    private javax.swing.JRadioButton m_disabledModeRadio;
    private javax.swing.JTextField m_feedbackText;
    private javax.swing.JToggleButton m_leftJoystickButton1;
    private javax.swing.JToggleButton m_leftJoystickButton2;
    private javax.swing.JToggleButton m_leftJoystickButton3;
    private javax.swing.JToggleButton m_leftJoystickButton4;
    private javax.swing.JLabel m_leftJoystickButtonsLabel;
    private javax.swing.JToggleButton m_leftJoystickTrigger;
    private javax.swing.JLabel m_leftJoystickXLabel;
    private javax.swing.JLabel m_leftLiftJagLabel;
    private javax.swing.JTextField m_leftLiftJagText;
    private javax.swing.JLabel m_leftWheelJagLabel;
    private javax.swing.JTextField m_leftWheelJagText;
    private javax.swing.ButtonGroup m_modeGroup;
    private javax.swing.JToggleButton m_rightJoystickButton1;
    private javax.swing.JToggleButton m_rightJoystickButton2;
    private javax.swing.JToggleButton m_rightJoystickButton3;
    private javax.swing.JToggleButton m_rightJoystickButton4;
    private javax.swing.JLabel m_rightJoystickButtonsLabel;
    private javax.swing.JLabel m_rightJoystickLabel;
    private javax.swing.JToggleButton m_rightJoystickTrigger;
    private javax.swing.JLabel m_rightLiftJagLabel;
    private javax.swing.JTextField m_rightLiftJagText;
    private javax.swing.JLabel m_rightWheelJagLabel;
    private javax.swing.JTextField m_rightWheelJagText;
    private javax.swing.JTextField m_shootCamJagText;
    private javax.swing.JLabel m_shootHopperJagLabel;
    private javax.swing.JTextField m_shootHopperJagText;
    private javax.swing.JLabel m_shootRotaryJagLabel;
    private javax.swing.JLabel m_shootRotaryJagLabel1;
    private javax.swing.JTextField m_shootRotaryJagText;
    private javax.swing.JRadioButton m_teleopModeRadio;
    private riverdale_emulator.JoystickWidget rightJoystick;
    // End of variables declaration//GEN-END:variables

    
    public boolean getDisabled()
    {
        return m_disabledModeRadio.isSelected();
    }

    public boolean getAutonomous()
    {
        return m_autonomousModeRadio.isSelected();
    }

    public boolean getOperatorControl()
    {
        return m_teleopModeRadio.isSelected();
    }
    
    public void setFeedback(String feedback)
    {
        m_feedbackText.setText(feedback);
    }
    
    public javax.swing.JToggleButton getTrigger(int port)
    {
        return port == 1 ? m_leftJoystickTrigger : m_rightJoystickTrigger;
    }
    
    public javax.swing.JToggleButton[] getButtons(int port)
    {
        javax.swing.JToggleButton buttons[] = new javax.swing.JToggleButton[4];
        if (port == 1)
        {
            buttons[0] = m_leftJoystickButton1;
            buttons[1] = m_leftJoystickButton2;
            buttons[2] = m_leftJoystickButton3;
            buttons[3] = m_leftJoystickButton4;
        }
        else if (port == 2)
        {
            buttons[0] = m_leftJoystickButton1;
            buttons[1] = m_leftJoystickButton2;
            buttons[2] = m_leftJoystickButton3;
            buttons[3] = m_leftJoystickButton4;
        }
        return buttons;   
    }
    
    public JoystickWidget getJoystick(final int port)
    {
        return port == 1 ? leftJoystick : rightJoystick; 
    }
    
    public javax.swing.JTextField getJaguar(final int channel)
    {
        if (channel == 3)
        {
            return m_leftWheelJagText;
        }
        else if (channel == 7)
        {
            return m_rightWheelJagText;
        }
        else if (channel == 10)
        {
            return m_leftLiftJagText;
        }
        else if (channel == 4)
        {
            return m_rightLiftJagText;
        }
        else if (channel == 2)
        {
            return m_shootRotaryJagText;
        }
        else if (channel == 5)
        {
            return m_shootHopperJagText;
        }
        else if (channel == 6)
        {
            return m_shootCamJagText;
        }
        return null;
    }

}
